﻿<%@ Page Title="Spa Appointment" Language="C#" MasterPageFile="~/Master/Site.Master"
    AutoEventWireup="true" CodeBehind="Spa AppointMent.aspx.cs" Inherits="SalonComplex.Appointment.SpaAppointMent" %>

<%@ Register TagPrefix="sc" TagName="ServiceControls" Src="~/Controls/ServicesControl.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../Styles/hotspot.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/cal.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/appointmentstyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Scripts/appointment.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.dateinput.min.js"></script>
    <script type="text/javascript">

        $(function () {

            // set up data input
            $('#TextBoxSpaDate').dateinput(
                {
                    format: 'm/d/yyyy',
                    min: -1,
                    max: 7
                });

            // add a click event to the grid view to check if the check limit has been exceeded
            $('#GridViewEmpSchedule :checked').live("click", function () {
                var result = $('#GridViewEmpSchedule :checked').not(':disabled');
                if (result.length > 3) {
                    alert('Cannot select more than three times');
                    $(this).attr('checked', false);
                }
            });

            //add employee id on the grid
            $('#GridViewEmpSchedule td label').hide();
            
            if ($('#LabelSpaAppDate').text().length > 1) {
                $('#successModal p').html($('#LabelSpaAppDate').text());
                $('#successModal').modal('show');
            }

        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div boomtime='left' id='part_ar_headline'>
    </div>
    <div boomtime='left' id='part_ar_intro'>
        <p class="appointText">
            <!--We will contact you to confirm your reservation via email and phone call in the
            next 12 hours.</p> -->
    </div>
    <form id="appt_request_form" action="/" method="post">
    <fieldset class="appointment" style="width: 750px;" id="appointment_info">
        <legend>Spa Appointment Information</legend>
        <div id="appt_services">
            <h2 id="value_service">Choose Services </h2>
            <dl>
                <div class="spacer">
                </div>
                <div boomtime="right" id="service_menu_edit" class="style13">
                    <div class="style14">
                        <dt style="width: 255px" class="style14">
                            <select id="service_cat" name="service_cat" runat="server" size="1" onchange="show_service_cat(this.value);">
                                <option value="17157">Nail Services</option>
                            </select>
                        </dt>
                    </div>
                    <div class="spacer">
                    </div>
                    <br />
                    <div class="style14">
                        Total $ <span id="service_value">0.00</span>
                    </div>
                    <br />
                    <div id="service">
                        <div>
                            <div>
                                <table id="services" class='table table-bordered table-striped'>
                                    <tr>
                                        <th></th>
                                        <th>Service Name</th>
                                        <th>Price</th>
                                    </tr>
                                    <asp:Repeater ID="rptServices" runat="server">
                                        <ItemTemplate>
                                            <sc:ServiceControls ID="ServiceControl" runat="server" Services="<%# Container.DataItem %>" />
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </dl>
        </div>
        <div id="appt_time">
            <h2 class="clearmargin">Select Appointment</h2>
            <div boomtime="right" id="hour_edit">
                <p class="alert alert-info span8 clearmargin">
                    Please select a date and enter any three (3) times (in order of preference) from
                    employee schedule below.
                </p>
                <table class="appoint_td">
                    <tr>
                        <td class="style27">
                            <p class="appoint_p">
                                <asp:Label ID="SalonServiceEmpLabel" runat="server" Style="font-size: medium; font-family: 'Segoe UI'"
                                    Text="Services:" Width="242px" Height="21px"></asp:Label>
                            </p>
                        </td>
                        <td class="style28">
                            <p class="appoint_p">
                                <asp:Label ID="LabelEnterAppDate" Text="Enter Appointment Date:" runat="server" Style="font-size: medium;
                                    font-family: 'Segoe UI'"></asp:Label>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td class="style27">
                            <p class="appoint_p">
                                <asp:DropDownList ID="DropDownListSpaServices" runat="server" AutoPostBack="true"
                                    DataSourceID="SqlDataSourceDropListServices" DataTextField="employee_type" DataValueField="employee_type"
                                    Height="25px" Width="200px" Enabled="False">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSourceDropListServices" runat="server" ConnectionString="<%$ ConnectionStrings:SalonConnectionString %>"
                                    SelectCommand="SELECT employee_type FROM employee WHERE (employee_type = 'Spa Services') GROUP BY employee_type">
                                </asp:SqlDataSource>
                            </p>
                        </td>
                        <td class="style28">
                            <p class="appoint_p" align="center">
                                <asp:TextBox ID="TextBoxSpaDate" runat="server" Height="22px" Width="200px" ClientIDMode="Static"
                                    AutoPostBack="True" placeholder="select a date"></asp:TextBox>
                            </p>
                        </td>
                    </tr>
                    <td class="style29">
                        <p class="appoint_p"></p>
                    </td>
                </table>
                <br />
                <br />
                <asp:GridView ID="GridViewEmpSchedule" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataSourceID="SqlDataSourceEmp" GridLines="None"
                    ClientIDMode="Static" CssClass="table">
                    <Columns>
                        <asp:BoundField DataField="sch_date" HeaderText="Schedule Date" SortExpression="sch_date"
                            DataFormatString="{0:d}" />
                        <asp:BoundField DataField="employee_fname" HeaderText="Employee Name" SortExpression="employee_fname" />
                        <asp:TemplateField HeaderText="8:00 am" SortExpression="8:00 am">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox10" runat="server" Checked='<%# Bind("[8:00 am]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox10" runat="server" Checked='<%# Bind("[8:00 am]") %>' Enabled='<%# ToggleEnabled(Eval("[8:00 am]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="9:00 am" SortExpression="9:00 am">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox9" runat="server" Checked='<%# Bind("[9:00 am]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox9" runat="server" Checked='<%# Bind("[9:00 am]") %>' Enabled='<%# ToggleEnabled(Eval("[9:00 am]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="10:00 am" SortExpression="10:00 am">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox8" runat="server" Checked='<%# Bind("[10:00 am]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox8" runat="server" Checked='<%# Bind("[10:00 am]") %>' Enabled='<%# ToggleEnabled(Eval("[10:00 am]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="11:00 am" SortExpression="11:00 am">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox7" runat="server" Checked='<%# Bind("[11:00 am]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox7" runat="server" Checked='<%# Bind("[11:00 am]") %>' Enabled='<%# ToggleEnabled(Eval("[11:00 am]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="12:00 pm" SortExpression="12:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox6" runat="server" Checked='<%# Bind("[12:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox6" runat="server" Checked='<%# Bind("[12:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[12:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="1:00 pm" SortExpression="1:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox5" runat="server" Checked='<%# Bind("[1:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox5" runat="server" Checked='<%# Bind("[1:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[1:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="2:00 pm" SortExpression="2:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox4" runat="server" Checked='<%# Bind("[2:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox4" runat="server" Checked='<%# Bind("[2:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[2:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="3:00 pm" SortExpression="3:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("[3:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("[3:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[3:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="4:00 pm" SortExpression="4:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("[4:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("[4:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[4:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="5:00 pm" SortExpression="5:00 pm">
                            <EditItemTemplate>
                                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("[5:00 pm]") %>' />
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("[5:00 pm]") %>' Enabled='<%# ToggleEnabled(Eval("[5:00 pm]").ToString()) %>'
                                    Text='<%# Bind("employee_id") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceEmp" runat="server" ConnectionString="<%$ ConnectionStrings:SalonConnectionString %>"
                    DeleteCommand="DELETE FROM [schedule] WHERE [employee_id] = @employee_id AND [schedule_id] = @schedule_id"
                    InsertCommand="INSERT INTO [schedule] ([sch_date], [8:00 am], [9:00 am], [10:00 am], [11:00 am], [12:00 pm], [1:00 pm], [2:00 pm], [3:00 pm], [4:00 pm], [5:00 pm], [employee_id]) VALUES (@sch_date, @column1, @column2, @column3, @column4, @column5, @column6, @column7, @column8, @column9, @column10, @employee_id)"
                    SelectCommand="SP_CheckEmployee" UpdateCommand="UPDATE [schedule] SET [sch_date] = @sch_date, [8:00 am] = @column1, [9:00 am] = @column2, [10:00 am] = @column3, [11:00 am] = @column4, [12:00 pm] = @column5, [1:00 pm] = @column6, [2:00 pm] = @column7, [3:00 pm] = @column8, [4:00 pm] = @column9, [5:00 pm] = @column10 WHERE [employee_id] = @employee_id AND [schedule_id] = @schedule_id"
                    SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="employee_id" Type="Int32" />
                        <asp:Parameter Name="schedule_id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter DbType="Date" Name="sch_date" />
                        <asp:Parameter Name="column1" Type="Boolean" />
                        <asp:Parameter Name="column2" Type="Boolean" />
                        <asp:Parameter Name="column3" Type="Boolean" />
                        <asp:Parameter Name="column4" Type="Boolean" />
                        <asp:Parameter Name="column5" Type="Boolean" />
                        <asp:Parameter Name="column6" Type="Boolean" />
                        <asp:Parameter Name="column7" Type="Boolean" />
                        <asp:Parameter Name="column8" Type="Boolean" />
                        <asp:Parameter Name="column9" Type="Boolean" />
                        <asp:Parameter Name="column10" Type="Boolean" />
                        <asp:Parameter Name="employee_id" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="TextBoxSpaDate" Name="SchDate" PropertyName="Text"
                            DefaultValue="" DbType="Date" />
                        <asp:ControlParameter ControlID="DropDownListSpaServices" DefaultValue="" Name="EmpType"
                            PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter DbType="Date" Name="sch_date" />
                        <asp:Parameter Name="column1" Type="Boolean" />
                        <asp:Parameter Name="column2" Type="Boolean" />
                        <asp:Parameter Name="column3" Type="Boolean" />
                        <asp:Parameter Name="column4" Type="Boolean" />
                        <asp:Parameter Name="column5" Type="Boolean" />
                        <asp:Parameter Name="column6" Type="Boolean" />
                        <asp:Parameter Name="column7" Type="Boolean" />
                        <asp:Parameter Name="column8" Type="Boolean" />
                        <asp:Parameter Name="column9" Type="Boolean" />
                        <asp:Parameter Name="column10" Type="Boolean" />
                        <asp:Parameter Name="employee_id" Type="Int32" />
                        <asp:Parameter Name="schedule_id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </div>
        <br />
        <p class="appointText">
            Anything else we should know about your desired services or appointment?
        </p>
        <dl>
            <p class="appointText">
                <asp:Label ID="AppCommentLabel" runat="server" Text="Comments:" Style="font-weight: 700"></asp:Label>
            </p>
            <asp:TextBox runat="server" ID="comment" Columns="35" Rows="8" Wrap="True" TextMode="MultiLine"
                CssClass="input-xxlarge"></asp:TextBox>
        </dl>
        <dl>
            <dd>
                <div id="SelectEmployee">
                    <asp:Button ID="SubmitAppButton" runat="server" Text="Submit Appointment" ValidationGroup="AddApp"
                        OnClick="SubmitAppButtonClick" OnClientClick="return validateAppointment();"
                        CssClass="btn btn-primary btn-large span2" ClientIDMode="Static" />
                    <asp:Button ID="Reset" runat="server" Text="Reset" OnClick="SubmitAppButtonClick"
                        CausesValidation="False" OnClientClick="salon.reset(); return false();" CssClass="btn btn-large span2"
                        ClientIDMode="Static" />
                    <br />
                </div>
        </dl>
        <div class="modal hide" id="myModal">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">×</button>
                <h3>Errors</h3>
            </div>
            <div class="modal-body">
                <p>One fine body…</p>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn btn-primary" onclick="$('#myModal').modal('hide');return false;">Close</a>
            </div>
        </div>
        <div id="successModal" class="modal hide fade" style="display: none;">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">×</button>
                <h3>Appointment Notification</h3>
            </div>
            <div class="modal-body">
            <p>
                <asp:Label ID="LabelSpaAppDate" runat="server" ForeColor="Red" Height="21px" Style="font-size: small"
                    Width="174px" ClientIDMode="Static"></asp:Label>
            </p>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn" data-dismiss="modal">Close</a>
            </div>
        </div>
    </fieldset>
    </form>
    <script type="text/javascript">
        service_calc();
    </script>
    <span id="content_in_end"></span>
    <div class="cleaner">
    </div>
</asp:Content>
